package ru.susu.algebra.partition.filter;

import ru.susu.algebra.partition.Partition;
import ru.susu.algebra.util.NumberUtilities;

/**
 * @author akargapolov
 * @since: 28.03.2009
 */
public class CentralUnitPartitionFilter implements IPartitionFilter
{
	@Override
	public boolean checkPartition(Partition partition)
	{
		boolean result = new DifferentOddFilter().checkPartition(partition);
		Integer[] array = partition.getArrayRepresentation();
		result = result && ((partition.getPresentedNumber() - array.length) % 4 == 0);
		result = result && !NumberUtilities.isFullSquare(array);
		return result;
	}

}
